using System;
using System.Collections.Generic;
using System.Text;
using Jbe.TestSuite.Infrastructure.Interface.Services;
using System.Windows.Forms;
using Jbe.TestSuite.Infrastructure.Module.Properties;
using Microsoft.Practices.CompositeUI.Utility;
using SCSFContrib.CompositeUI.WinForms;

namespace Jbe.TestSuite.Infrastructure.Module.EditAdapters
{
    public class TextBoxAdapterFactory : IAdapterFactory<IEditHandler>
    {
        public IEditHandler GetAdapter(object element)
        {
            Guard.ArgumentNotNull(element, "element");

            if (element is System.Windows.Controls.TextBox)
            {
                return new WPFTextBoxAdapter((System.Windows.Controls.TextBox)element);
            }
            else if (element is RichTextBox)
            {
                return new RichTextBoxAdapter((RichTextBox)element);
            }
            else if (element is TextBoxBase) 
            {
                return new TextBoxBaseAdapter((TextBoxBase)element);
            }

            throw new ArgumentException(Resources.ArgumentNotSupported);
        }

        public bool Supports(object element)
        {
            Guard.ArgumentNotNull(element, "element");

            return (element is System.Windows.Controls.TextBox || element is TextBoxBase);
        }
    }
}
